package psi

import (
	"strings"

	"github.com/sirupsen/logrus"
)

/*
拨打电话
平台发送:
[DW*YYYYYYYYYYYYYYY*LEN*CALL,电话号码]
实例:[DW*334588000000156*0010*CALL,00000000000]
终端回复:
[DW*YYYYYYYYYYYYYYY*LEN*CALL]
实例:[DW*334588000000156*0004*CALL]
说明:终端收到该指令就会拨打相应指令里面设置的手机号码
*/
type CALL struct {
	PhoneNumber string // 电话号码
}

func DealCALL(method string, params map[string]interface{}) (string, error) {
	var call CALL
	err := MapToStruct(params, &call)
	if err != nil {
		logrus.Error("MapToStruct error:", err)
		return "", err
	}
	var messageList []string
	messageList = append(messageList, "CALL")
	messageList = append(messageList, call.PhoneNumber)
	message := strings.Join(messageList, ",")
	return message, nil
}
